package com.longrise.co.ui.carfiles.adapter;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.longrise.co.R;
import com.longrise.co.ui.carfiles.model.ItemRepairDetailEntity;
import com.longrise.co.ui.carfiles.model.ItemTitleBean;
import com.longrise.co.ui.carfiles.model.RepairRecordDetail;
import com.longrise.co.utils.Constants;

import java.util.List;


/**
 * Created by admin on 2017/2/4.
 */

public class RepairDetailAdapter extends BaseMultiItemQuickAdapter<ItemRepairDetailEntity> {


    public RepairDetailAdapter(List<ItemRepairDetailEntity> listData) {
        super(listData);
        addItemType(Constants.REPAIR_DETAIL_TYPE_ONE, R.layout.item_repair_detail_title);
        addItemType(Constants.REPAIR_DETAIL_TYPE_TWO, R.layout.item_repair_parts);
        addItemType(Constants.REPAIR_DETAIL_TYPE_THREE, R.layout.item_repair_project);

    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, ItemRepairDetailEntity o) {

        switch (baseViewHolder.getItemViewType()) {
            case Constants.REPAIR_DETAIL_TYPE_ONE :
                ItemTitleBean titleBean = (ItemTitleBean)o.getObj();
                baseViewHolder.setText(R.id.title, titleBean.getName())
                              .setBackgroundRes(R.id.arrow_right, titleBean.isExpansion() ? R.drawable.top : R.drawable.arrow_right);
                break;
            case Constants.REPAIR_DETAIL_TYPE_TWO :
                    RepairRecordDetail.LcipmaterialsBean partBean = (RepairRecordDetail.LcipmaterialsBean) o.getObj();
                    baseViewHolder
                            .setText(R.id.name_value, partBean.getPartsname())
                            .setText(R.id.no_value, partBean.getPartscode())
                            .setText(R.id.count_value, partBean.getPartsquantity());
                break;
            case Constants.REPAIR_DETAIL_TYPE_THREE :
                    RepairRecordDetail.LciptimesheetBean sheetBean = (RepairRecordDetail.LciptimesheetBean) o.getObj();
                    baseViewHolder
                            .setText(R.id.project_value, sheetBean.getRepairproject())
                            .setText(R.id.time_value, sheetBean.getWorkinghours());
                break;
        }
    }
}
